/* 
 * 监听js
 * 监听网络状态
 * 监听消息数量
 * 监听前后台
 */
document.addEventListener("netchange", onNetChange, false);

function onNetChange() {
	var nt = plus.networkinfo.getCurrentType();
	switch(nt) {
		case plus.networkinfo.CONNECTION_ETHERNET:
		case plus.networkinfo.CONNECTION_WIFI:
		case plus.networkinfo.CONNECTION_CELL2G:
		case plus.networkinfo.CONNECTION_CELL3G:
		case plus.networkinfo.CONNECTION_CELL4G:
			plus.nativeUI.closeWaiting();
			var message = plus.webview.getWebviewById('Msg');
			mui.fire(message, 'internet', {
				internet: true
			});
			break;
		default:
			var message = plus.webview.getWebviewById('Msg');
			mui.fire(message, 'internet', {
				internet: false
			});
			plus.nativeUI.showWaiting('网络好像不通了···');
			break
	}
}

window.addEventListener('newmessages', function(event) {
	var wds = event.detail.weidu;
	if(wds > 0) {
		document.getElementById('numm').style.display = 'block';
		document.getElementById('numm').innerHTML = wds
	} else {
		document.getElementById('numm').style.display = 'none'
	}
});
//点击推送信息打开聊天窗口